package com.openbravo.beans;

import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.swing.JPanel;

public class JClockPanel extends JPanel
{
  private static Calendar m_calendar = new GregorianCalendar();
  private Date m_date;
  private boolean m_bSeconds;
  private long m_lPeriod;

  public JClockPanel()
  {
    this(true);
  }

  public JClockPanel(boolean paramBoolean)
  {
    initComponents();
    this.m_bSeconds = paramBoolean;
    this.m_date = null;
    this.m_lPeriod = 0L;
  }

  public void setSecondsVisible(boolean paramBoolean)
  {
    this.m_bSeconds = paramBoolean;
    repaint();
  }

  public boolean isSecondsVisible()
  {
    return this.m_bSeconds;
  }

  public void setPeriod(long paramLong)
  {
    if (paramLong >= 0L)
    {
      this.m_lPeriod = paramLong;
      repaint();
    }
  }

  public long getPeriod()
  {
    return this.m_lPeriod;
  }

  public void setTime(Date paramDate)
  {
    this.m_date = paramDate;
    repaint();
  }

  public Date getTime()
  {
    return this.m_date;
  }

  public void paintComponent(Graphics paramGraphics)
  {
    super.paintComponent(paramGraphics);
    int i = getWidth();
    int j = getHeight();
    double d1 = 0.0D;
    double d2 = 0.0D;
    double d3 = 0.0D;
    if (this.m_date != null)
    {
      m_calendar.setTime(this.m_date);
      d1 = m_calendar.get(11);
      d2 = m_calendar.get(12);
      d3 = m_calendar.get(13);
    }
    Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
    localGraphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    Paint localPaint = localGraphics2D.getPaint();
    AffineTransform localAffineTransform1 = localGraphics2D.getTransform();
    int k = i / 2;
    int m = j / 2;
    int n = Math.min(k, m);
    localGraphics2D.transform(AffineTransform.getTranslateInstance(k, m));
    localGraphics2D.transform(AffineTransform.getScaleInstance(n / 1100.0D, n / 1100.0D));
    AffineTransform localAffineTransform2 = localGraphics2D.getTransform();
    localGraphics2D.setPaint(isEnabled() ? new GradientPaint(-1200.0F, -1200.0F, Color.BLUE, 1200.0F, 1200.0F, Color.CYAN) : new GradientPaint(-1200.0F, -1200.0F, Color.GRAY, 1200.0F, 1200.0F, Color.LIGHT_GRAY));
    localGraphics2D.fillOval(-1000, -1000, 2000, 2000);
    localGraphics2D.setPaint(isEnabled() ? new GradientPaint(-1200.0F, -1200.0F, Color.CYAN, 1200.0F, 1200.0F, Color.BLUE) : new GradientPaint(-1200.0F, -1200.0F, Color.LIGHT_GRAY, 1200.0F, 1200.0F, Color.GRAY));
    localGraphics2D.fillOval(-900, -900, 1800, 1800);
    localGraphics2D.setColor(Color.BLACK);
    localGraphics2D.drawOval(-1000, -1000, 2000, 2000);
    for (int i1 = 0; i1 < 60; i1++)
    {
      localGraphics2D.setColor(Color.WHITE);
      localGraphics2D.fillRect(900, -5, 50, 10);
      localGraphics2D.transform(AffineTransform.getRotateInstance(0.1047197551196598D));
    }
    localGraphics2D.setTransform(localAffineTransform2);
    for (int i1 = 0; i1 < 12; i1++)
    {
      localGraphics2D.setColor(Color.WHITE);
      localGraphics2D.fillRect(800, -15, 150, 30);
      localGraphics2D.transform(AffineTransform.getRotateInstance(0.5235987755982988D));
    }
    if (this.m_date != null)
    {
      localGraphics2D.setTransform(localAffineTransform2);
      localGraphics2D.transform(AffineTransform.getRotateInstance((d1 + d2 / 60.0D) * 3.141592653589793D / 6.0D));
      if (this.m_lPeriod > 0L)
      {
       int  i1 = (int)(this.m_lPeriod / 120000L);
        localGraphics2D.setColor(new Color(255, 255, 255, 100));
        localGraphics2D.fillArc(-1000, -1000, 2000, 2000, 90 - i1, i1);
        localGraphics2D.setColor(Color.DARK_GRAY);
        localGraphics2D.drawArc(-1000, -1000, 2000, 2000, 90 - i1, i1);
      }
      else
      {
        localGraphics2D.setColor(Color.WHITE);
        localGraphics2D.fillPolygon(new int[] { 0, -35, 0, 35 }, new int[] { 100, 0, -600, 0 }, 4);
        localGraphics2D.setColor(Color.DARK_GRAY);
        localGraphics2D.drawPolygon(new int[] { 0, -35, 0, 35 }, new int[] { 100, 0, -600, 0 }, 4);
        localGraphics2D.setTransform(localAffineTransform2);
        localGraphics2D.transform(AffineTransform.getRotateInstance(d2 * 3.141592653589793D / 30.0D));
        localGraphics2D.setColor(Color.WHITE);
        localGraphics2D.fillPolygon(new int[] { 0, -35, 0, 35 }, new int[] { 100, 0, -900, 0 }, 4);
        localGraphics2D.setColor(Color.DARK_GRAY);
        localGraphics2D.drawPolygon(new int[] { 0, -35, 0, 35 }, new int[] { 100, 0, -900, 0 }, 4);
        if (this.m_bSeconds)
        {
          localGraphics2D.setTransform(localAffineTransform2);
          localGraphics2D.transform(AffineTransform.getRotateInstance(d3 * 3.141592653589793D / 30.0D));
          localGraphics2D.setColor(Color.YELLOW);
          localGraphics2D.fillPolygon(new int[] { -15, 0, 15 }, new int[] { 200, -900, 200 }, 3);
          localGraphics2D.setColor(Color.DARK_GRAY);
          localGraphics2D.drawPolygon(new int[] { -15, 0, 15 }, new int[] { 200, -900, 200 }, 3);
          localGraphics2D.setTransform(localAffineTransform2);
          localGraphics2D.setColor(Color.YELLOW);
          localGraphics2D.fillOval(-25, -25, 50, 50);
          localGraphics2D.setColor(Color.DARK_GRAY);
          localGraphics2D.drawOval(-25, -25, 50, 50);
        }
      }
    }
    localGraphics2D.setColor(Color.WHITE);
    localGraphics2D.fillOval(-10, -10, 20, 20);
    localGraphics2D.setColor(Color.BLACK);
    localGraphics2D.drawOval(-10, -10, 20, 20);
    localGraphics2D.setTransform(localAffineTransform1);
    localGraphics2D.setPaint(localPaint);
  }

  private void initComponents()
  {
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.beans.JClockPanel
 * JD-Core Version:    0.6.0
 */